package com.zmj.mobile.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zmj.framework.base.service.impl.BaseServiceImpl;
import com.zmj.mobile.entity.UserEntity;
import com.zmj.mobile.mapper.IUserMapper;
import com.zmj.mobile.service.IUserService;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>

 * </p>
 *
 * @author lzy
 * @since 2024-02-01
 */
@Service
public class UserServiceImpl extends BaseServiceImpl<IUserMapper, UserEntity> implements IUserService {

    @Override
    public List<UserEntity> getListById(List<Integer> idList) {
        LambdaQueryWrapper<UserEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(UserEntity::getId, idList);
        queryWrapper.eq(UserEntity::getIsDeleted, 0);

        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public UserEntity getOneByName(String userName) {
        LambdaQueryWrapper<UserEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(UserEntity::getUsername, userName);
        queryWrapper.eq(UserEntity::getIsDeleted, 0);
        queryWrapper.last("limit 1");

        return baseMapper.selectOne(queryWrapper);
    }
}
